<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Document</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width, initial-scale=1" name="viewport"/>
	<meta content="" name="description"/>
	<meta content="" name="author"/>
	<!-- BEGIN GLOBAL MANDATORY STYLES -->
	<link href="./Public/Admin/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="./Public/Admin/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
	<link href="./Public/Admin/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	
	<!-- BEGIN THEME STYLES -->
	<link href="./Public/Admin/assets/global/css/components.css" id="style_components" rel="stylesheet" type="text/css"/>
	
	<link href="./Public/Admin/assets/admin/layout/css/layout.css" rel="stylesheet" type="text/css"/>
	<!--<link href="./Public/Admin/assets/admin/layout/css/themes/darkblue.css" rel="stylesheet" type="text/css" id="style_color"/>-->
	
	<!-- END THEME STYLES -->
	<link rel="shortcut icon" href="favicon.ico"/>
	<!--百度编辑器-->
	<script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
    <!--异步上传图片-->
    <script type="text/javascript" src="Public/uploadify/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="Public/uploadify/jquery.uploadify.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Public/uploadify/uploadify.css">
 <base target="iframe"/>
</head>
<body>
	<form action="" method="post" enctype="multipart/form-data">
		<fieldset>
			<legend>添加商品</legend>
			<table class="table table-bordered table-hover">
				<thead>
					<tr>
						<th colspan="2" class="btn btn-primary">基本信息</th>
					</tr>
				</thead>
				<tbody>
					<tr class="info">
						<td>所属分类</td>
						<td>
							<select name="classify_cid">
								<option value="0">-请选择-</option>
								
								<?php foreach ($cate as $v){?>
								
								<option value="<?php echo $v['cid']?>" tid="<?php echo $v['type_tid']?>"><?php echo $v['_name']?></option>
								<?php }?>
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>所属品牌</td>
						<td>
							<select name="brand_bid">
								<option value="0">-请选择-</option>
								<?php foreach ($brand as $v){?>
								<option value="<?php echo $v['bid']?>"><?php echo $v['bname']?></option>
								<?php }?>
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>商品名称</td>
						<td>
							<input type="text" name="gname">
						</td>
					</tr>
					<tr class="info">
						<td>单位</td>
						<td>
							<input type="text" name="gunit" value="部">
						</td>
					</tr>
					<tr class="info">
						<td>市价场</td>
						<td>
							<input type="text" name="gmprice">
						</td>
					</tr>
					<tr class="info">
						<td>商城价</td>
						<td>
							<input type="text" name="gprice">
						</td>
					</tr>
					<tr class="info">
						<td>点击次数</td>
						<td>
							<input type="text" name="gclick" value="0">
						</td>
					</tr>
				</tbody>
			</table>

			<p class="btn btn-primary">商品属性</p>
			<table class="table table-bordered table-hover" id="attr" class="info">
				
			</table>
			<p class="btn btn-primary">商品规格</p>
			<table class="table table-bordered table-hover" id="spec">
				
			</table>

			<table class="table table-bordered">
				<tbody><tr>
					<th colspan="3" class="btn btn-primary">列表图</th>
				</tr>
				<tr class="info">
					<td>上传图片</td>
					<td colspan="2">
						<div lab="uploadFile1">
						    <input id="f1" type="file" multiple="true" name="glistimg">
						    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						    <script type="text/javascript">
						        $(function() {
						            $('#f1').uploadify({
						                'formData'     : {//POST数据
						                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                },
						                'fileTypeDesc' : '上传文件',//上传描述
						                'fileTypeExts' : '*.jpg;*.png',
						                'swf'      : '<?php echo __PUBLIC__?>/uploadify/uploadify.swf',
						                'uploader' : '<?php echo U('upload')?>',
						                'buttonText':'选择文件',
						                'fileSizeLimit' : '2000KB',
						                'uploadLimit' : 10,//上传文件数
						                'width':65,
						                'height':25,
						                'successTimeout':10,//等待服务器响应时间
						                'removeTimeout' : 0.2,//成功显示时间
						                'onUploadSuccess' : function(file, data, response) {
						                    //转为json
						                    data=$.parseJSON(data);
						                    //获得图片地址
						                    var imageUrl = data.url;
						                    var li="<li><img src='"+imageUrl+"'/><input type='hidden' name='glistimg' value='"+data.path+"'/></li>";
						                    $("#uploadList1 ul").prepend(li);
						                }
						            });
						        });
						    </script>
    						<div id="uploadList1">
      							<ul>

        						</ul>
    						</div>
						</div>
						</td>
				</tr>
			</tbody></table>

			<table class="table table-bordered">
				<tbody><tr>
					<th colspan="3" class="btn btn-primary">商品图册</th>
				</tr>
				<tr class="info">
					<td >上传图片</td>
					<td colspan="2">
						<div lab="uploadFile">
						    <input id="f2" type="file" multiple="true">
						    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						    <script type="text/javascript">
						        $(function() {
						            $('#f2').uploadify({
						                'formData'     : {//POST数据
						                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                },
						                'fileTypeDesc' : '上传文件',//上传描述
						                'fileTypeExts' : '*.jpg;*.png',
						                'swf'      : '<?php echo __PUBLIC__?>/uploadify/uploadify.swf',
						                'uploader' : '<?php echo U('upload')?>',
						                'buttonText':'选择文件',
						                'fileSizeLimit' : '2000KB',
						                'uploadLimit' : 10,//上传文件数
						                'width':65,
						                'height':25,
						                'successTimeout':10,//等待服务器响应时间
						                'removeTimeout' : 0.2,//成功显示时间
						                'onUploadSuccess' : function(file, data, response) {
						                    //转为json
						                    data=$.parseJSON(data);
						                    //获得图片地址
						                    var imageUrl = data.url;
						                    var li="<li><img src='"+imageUrl+"'/><input type='hidden' name='dimg[]' value='"+data.path+"'/></li>";
						                    $("#uploadList ul").prepend(li);
						                }
						            });
						        });
						    </script>
    						<div id="uploadList">
      							<ul>

        						</ul>
    						</div>
						</div>
						
						
					</td>
				</tr>
			</tbody></table>

			<table class="table">
				<tbody><tr class="next_show">
					<th class="btn btn-primary">商品内容</th>
				</tr>
				<tr class="info">
					<td>
					<!--调用百度编辑器-->
					<script id="editor1" type="text/plain" style="width:100%;height:500px;" name="dcontent"></script>
		    		<script>
		        		var ue = UE.getEditor('editor1');
		   			 </script>
					</td>
				</tr>
			</tbody></table>

			<table class="table">
				<tbody><tr class="next_show">
					<th class="btn btn-primary">售后服务</th>
				</tr>
				<tr class="info">
					<td>
						<!--调用百度编辑器-->
						<script id="editor" type="text/plain" style="width:100%;height:500px;" name="dservice"></script>
		    			<script>
		        			var ue = UE.getEditor('editor');
		  	  			</script>
					</td>
				</tr>
			</tbody></table>
			<input type="hidden" name="tid" value="0">
			<input type="hidden" name="type_tid" value="0">
			<input type="submit" value="确认添加" class="btn btn-primary btn-block btn-large">
		</fieldset>
	</form>
	<script type="text/javascript">
		$(function(){
			$('[name=classify_cid]').change(function(){
				var tid=$('option:selected').attr('tid');
				$('[name=type_tid]').val(tid);
				$.ajax({
					type:"post",
					url:"<?php echo U('getTypeAttr')?>",
					data:{id:tid},
					dataType:'json',
					success:function(phpData){
						//规格（可选）
						var spec='';
						//属性(不可选)
						var attr='';
						$.each(phpData,function(k,v){
							//规格
							if(v.type==1){
								spec+='<tr class="info">'+
								'<td>'+v.attname+'</td>'+
								'<td>'+
									'<select name="spec['+v.taid+'][value][]" id=""><option value="">请选择</option>';
										$.each(v.attvalue,function(kk,vv){
											spec+='<option value="'+vv+'">'+vv+'</option>';
										});
									spec +='</select></td><td>附加价格：<input type="text" name="spec['+v.taid+'][price][]" id="" /></td>'+'<td><span class="btn btn-success add-spec">増加规格</span></td></>';	
							}else{
								
								
								attr+='<tr class="info">'+
										'<td>'+v.attname+'</td>'+
										'<td>'+
										'<select name="attr['+v.taid+']" id=""><option value="">请选择</option>';
										$.each(v.attvalue,function(kk,vv){
											attr+='<option value="'+vv+'">'+vv+'</option>';
										});
								attr +='</select></td></tr>';
							}
						});
						//$.each
						//插入属性
						$('#attr').html(attr);
						$('#spec').html(spec);
					}
					//success
				});
				//ajax
			})
			//异步结束
			//点击添加规格
			$('.add-spec').live('click',function(){
				//找到父级的tr
				var parentsTr=$(this).parents('tr');
				//把父级的tr克隆复制
				var cloneTr=parentsTr.clone();
				cloneTr.find('.add-spec').removeClass('add-spec btn-success').addClass('remove-spec btn-danger').html('删除规格');
				//插入下一行
				parentsTr.after(cloneTr);
			})
			//删除规格
			$('.remove-spec').live('click',function(){
				$(this).parents('tr').remove();
			})
			
			
			
			
			
		})
	</script>
</body>
</html>




























































